<?php
!defined('IN_FENGTOPsso') && exit('Access Denied');

class LogOut extends Base{
	private $ticket;
	private $userName;
	private $domain = array();
	
	public function __construct() {
		parent::__construct();
		$this->ticket   = $_COOKIE['ticket'];
		$this->userName = $_SESSION['FOnlineUser']['user'];
	}
	
	public function clearTicket() {
		$this->getCliect();
		
		for ($i = 0; $i < count($this->domain); $i++) {
			setcookie("uid"            , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("username"       , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("password"       , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("email"          , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("user_sex"       , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("status"         , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("emailstatus"    , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("regdate"        , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("regip"          , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("lastlogintime"  , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("lastloginip"    , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("question"       , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("uanswer"        , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("ticket"         , '' , time() - 1, "/", $this->domain[$i]['domain']); 
//			setcookie("PHPSESSID"      , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			setcookie("FT_auth"        , '' , time() - 1, "/", $this->domain[$i]['domain']); 
			foreach($_COOKIE['user'] as $wordId => $value){
				setcookie("user[$wordId]","",time() - 1, "/", $this->domain[$i]['domain']);
			}
		}
	}
	
	public function delOnLine() {
		$deletSql = "DELETE FROM `{$GLOBALS['_FENGTOPsso']['db']['1']['tablepre']}onlineuser` WHERE `ticket` = '".$this->ticket."'";
		$result = $this->mysqldb->Query($deletSql);
	}
	
	private function getCliect(){
		$selectAllClientDomain = "SELECT `domain` FROM `{$GLOBALS['_FENGTOPsso']['db']['1']['tablepre']}client`";
		$this->domain = $this->mysqldb->GetAll($selectAllClientDomain);
	}
}


?>